﻿using System;
using System.Collections.Generic;
using System.Text;
using Lswweb.Domain;
using Lswweb.Model;
using Lswweb.Common;

namespace Lswweb.Controls
{
    public class DeleteHandler : ModelHandler
    {
        protected override void Handler(int id, SiteModule type)
        {
            switch (type)
            {
                case SiteModule.User:
                    Users.Delete(Convert.ToInt32(id));
                    break;
                case SiteModule.News:
                    News.Delete(Convert.ToInt32(id));
                    break;
                case SiteModule.Product:
                    Products.Delete(Convert.ToInt32(id));
                    break;
                case SiteModule.Subscribe:
                    Subscribe.Delete(Convert.ToInt32(id));
                    break;
                case SiteModule.UpFile:
                    UpFiles.Delete(Convert.ToInt32(id));
                    break;
                case SiteModule.Links:
                    Links.Delete(Convert.ToInt32(id));
                    break;
                case SiteModule.Order:
                    Orders.Delete(Convert.ToInt32(id));
                    break;
                case SiteModule.Commentary:
                    Products.DeleteCommentary(Convert.ToInt32(id));
                    break;
                case SiteModule.GuestBook:
                    GuestBook.Delete(Convert.ToInt32(id));
                    break;
                case SiteModule.ProductStorage:
                    ProductStorage.Delete(Convert.ToInt32(id));
                    break;
                case SiteModule.Message:
                    Messages.Delete(Convert.ToInt32(id));
                    break;
                case SiteModule.Currency:
                    CurrencyServices.Delete(Convert.ToInt32(id));
                    break;
                case SiteModule.WholesaleRule:
                    ProductWholesaleRule.Delete(id.As<int>());
                    break;
                case SiteModule.Newsletter:
                    Newsletter.Delete(id.As<int>());
                    break;
                case SiteModule.LogisticsCompany:
                    LogisticsCompanyServices.Delete(id.As<int>());
                    break;
                default:
                    SiteContext.RenderMessage(ExceptionType.PageNotFond, SiteContext.Current.ReferrerUrl);
                    break;
            }
        }
    }
}
